<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_Logon extends CI_Model {
    
    function __construct() {
        parent::__construct();   
    }
    
    public function getUser($user, $pass){
        $sql='select m_database_sekolah.NAME as db_name, m_database_sekolah.NAMA_SEKOLAH as school_name, user.NAMA as user_name  from user left join m_database_sekolah on user.ADMIN_SEKOLAH = m_database_sekolah.id where NAMA= ? and PASSWORD= ?';
        $query = $this->db->query($sql,array($user,$pass));
        foreach ($query->result() as $row) {
           $this->session->set_userdata("db_name",$row->db_name);
           $this->session->set_userdata("school_name",$row->school_name);
           $this->session->set_userdata("user_name",$row->user_name);
        }
        return $query;
    }
    
}
